Skip to content

Prevent IndexOutOfBoundsException when using translation patches#7

Open
agarciacif wants to merge 1 commit into
emiyl:mainfrom
agarciacif:main
Open

Prevent IndexOutOfBoundsException when using translation patches#7
agarciacif wants to merge 1 commit into
emiyl:mainfrom
agarciacif:main

Conversation

@agarciacif

Copy link
Copy Markdown

When applying a fan translation patch (e.g., Traducciones-Kurain/PWTrilogy-ESP), the game adds a new language entry. This causes the language value read from languageAddr (0x12D4) to exceed the expected range (> 6). Since the combobox only supports up to index 6, accessing index 7 or higher throws an IndexOutOfBoundsException, preventing the combobox from rendering.

If the language value exceeds the size of textList, default it to 0 to ensure the combobox always renders safely.

I’m not very familiar with savegame handling, but a possible improvement could be to read all textValues directly from the game instead of hardcoding them in arrays. I’m not sure if this is technically possible, but if it is, it could make this solution more flexible.

Ensures self.values[i] does not exceed the length of textList before setting the combo box value, preventing IndexError during initialization.
@agarciacif agarciacif mentioned this pull request Aug 21, 2025
@agarciacif

agarciacif commented Aug 21, 2025

Copy link
Copy Markdown
Author
image The first screenshot shows the additional language added by the fan translation patcher. image The second screenshot illustrates the issue: when the tool reads a language value that falls outside the expected range, the comboBox fails to render correctly.

My fix defaults to the first value (Japanese), ensuring the tool can save the modified data even when the language value is out of range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant